package com.romotc.qqrobot.config.bean;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

import com.romotc.json.tools.Jackson;
import com.romotc.oschina.bean.POJO;

/**
 * webQq各种url数据拦截、记录配置类
 * @author Administrator
 *
 */
public class QQUrlWatcherConfig extends POJO {

	protected boolean IsObjectCachedByID() { return true; }
	/**
	 * url 支持末尾为*
	 */
	private String url;
	
	/**
	 * 拦截（对请求进行完全拦截或请求、响应信息加盐）处理类
	 */
	private String catchingClass;
	
	/**
	 * 对请求的结果进行处理、记录的处理类
	 */
	private String logClass;
	
	/**
	 * 如果对一个url配置了多个拦截类 按照其processOrder的大小顺序执行
	 */
	private int processOrder;
	
	/**
	 * 取代之前通过文件配置中的logLevel
	 */
	private int logLevel = 0;
	
	/**
	 * 文件 日志 位置（需logLevel 配置为非-9 配置为>0则可使用requestSpy日志记录）
	 */
	private String logFileName;
	
	/**
	 * 备注
	 */
	private String note;
	
	public int getLogLevel() {
		return logLevel;
	}




	public void setLogLevel(int logLevel) {
		this.logLevel = logLevel;
	}




	public String getLogFileName() {
		return logFileName;
	}




	public void setLogFileName(String logFileName) {
		this.logFileName = logFileName;
	}




	public QQUrlWatcherConfig() {
		
	}
	
	
	
	
	//getter && settle
	public String getUrl() {
		return url;
	}



	public void setUrl(String url) {
		this.url = url;
	}



	public String getCatchingClass() {
		return catchingClass;
	}



	public void setCatchingClass(String catchingClass) {
		this.catchingClass = catchingClass;
	}



	public String getLogClass() {
		return logClass;
	}



	public void setLogClass(String logClass) {
		this.logClass = logClass;
	}
	public int getProcessOrder() {
		return processOrder;
	}




	public void setProcessOrder(int processOrder) {
		this.processOrder = processOrder;
	}
	
	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args){
		// TODO Auto-generated method stub
//		QQUrlWatcherConfig config = new QQUrlWatcherConfig();
//		config.setUrl("*.qq.com*");
//		config.setCatchingClass("CatchingClass");
//		config.setLogClass("CatchingClass");
//		config.Save();
		
		String path = "D:\\romotc\\dev\\scache-0.94\\conifg\\RequestSpyConfig.txt";
		try {
			String content = FileUtils.readFileToString(new File(path));
			QQUrlWatcherConfig config = Jackson.getObjectMaper().readValue(content, QQUrlWatcherConfig.class);
			System.out.println(config.getUrl());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}





}
